home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / CIncludesTool 1.0 / original version / CIncludesTool next >
Encoding:
Text File  |  1990-07-31  |  2.2 KB  |  97 lines  |  [TEXT/MPS ]

  1. # Script for CIncludes Tool  - by John Jeppson
  2.  
  3. set exit 0
  4. set param 0
  5. set toolStatus 0
  6.  
  7. if {#} == 1
  8.     if ("{1}" == "-m") || ("{1}" == "-M")
  9.         set param 1
  10.     else if ("{1}" == "-f") || ("{1}" == "-F")
  11.         set param 2
  12.     else if ("{1}" == "-i") || ("{1}" == "-I")
  13.         set param 3
  14.     else if ("{1}" == "-d") || ("{1}" == "-D")    # Daniel Grassi
  15.         set param 4
  16.     end
  17. end
  18.         
  19. if {param} == 0
  20.     beep
  21.     echo
  22.     echo 'CIncludesTool must be called with a single parameter:'
  23.     echo '   -f  Locates selection from active window'
  24.     echo '   -m  Rebuilds the CIncludes identifier dictionary'
  25.     echo '   -i  Reformats "#include" statements in selection'
  26.     echo '   -d  Displays the "#include" file declaring the selection'  # Daniel Grassi
  27.     echo
  28.  
  29. else if {param} == 1
  30.     find §:/∞/ "{Active}"; find §Δ "{Active}"; echo
  31.     CIncludesCode -m `files -f {CIncludes}≈.h`
  32.     set toolStatus "{Status}"
  33.     Beep 2C,20,128
  34.  
  35. else if {param} == 2
  36.     Mark -y § x162534 "{Active}"
  37.  
  38.     set str  "`catenate "{Active}".§`"
  39.     CIncludesCode -v "{str}"
  40.     set toolStatus "{Status}"
  41.  
  42.     if {toolStatus} == 0
  43.         find   • "{Active}"
  44.         find Δ/#include/ "{Active}"              # Daniel Grassi
  45.         CIncludesCode -f "{str}"
  46.         set toolStatus "{Status}"
  47.     end
  48.     
  49.     find   x162534 "{Active}"
  50.     UnMark x162534 "{Active}"
  51.  
  52. else if {param} == 3
  53.     CIncludesCode -i "{Active}.§"
  54.     set toolStatus "{Status}"
  55.  
  56. else if {param} == 4                            # Daniel Grassi
  57.         set str  "`catenate "{Active}".§`"
  58.         CIncludesCode -v "{str}"
  59.         set toolStatus "{Status}"
  60.  
  61.         if {toolStatus} == 0
  62.             set counter 1
  63.             for i in `CIncludesCode -d "{str}"`
  64.                 if {counter} == 1
  65.                     open -r {CIncludes}"{i}"
  66.                     set counter 2
  67.                 else
  68.                     find •!{i} "{Active}"
  69.                     find \{str}\ "{Active}"
  70.                 end
  71.             end
  72.             set toolStatus "{Status}"
  73.         end
  74. end
  75.  
  76.  
  77. if {toolStatus}
  78.     beep
  79.     echo
  80.  
  81.     if      {toolStatus} == '1'
  82.         echo 'Bad Parameters to "CIncludesCode"'    # won't occur here
  83.     else if {toolStatus} == '2'
  84.         echo 'Invalid Identifier!'
  85.     else if {toolStatus} == '3'
  86.         if ({param} == 2) || (param} == 3)
  87.             echo 'Unable to Load DataBase Resource!'
  88.         else
  89.             echo 'Out of Memory error!'
  90.         end
  91.     else if {toolStatus} == '4'
  92.         echo 'Identifier not found in CIncludes!'
  93.     end
  94.  
  95.     echo
  96. end
  97.